﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Study.Test
{
    public class foreach异步问题测试
    {
        public static async void Go()
        {
            List<int> list = new List<int>();
            for (int i = 0; i < 10_0000; i++)
            {
                list.Add(i);
            }


            foreach (int i in list)
            {
                await WriteAsync(i);
            }
        }

        public static async Task WriteAsync(int i)
        {
            await Task.Delay(new Random().Next(50, 300));
            Console.WriteLine(i);
        }
    }
}
